package com.muyu.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.muyu.domain.WarnStrategy;

import com.muyu.domain.req.WarnStrategyReq;
import com.muyu.domain.resp.WarnStrategyResp;
import com.muyu.mapper.WarnLogsMapper;
import com.muyu.mapper.WarnStrategyMapper;
import com.muyu.service.WarnStrategyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.common.core.utils.StringUtils;
import org.springframework.util.Assert;

import java.util.List;

/**
 * 预警策略Service业务层处理
 *
 * @author muyu
 * @date 2024-09-20
 */
@Service
public class WarnStrategyServiceImpl
        extends ServiceImpl<WarnStrategyMapper, WarnStrategy>
        implements WarnStrategyService {
    @Autowired
    private WarnStrategyMapper warnStrategyMapper;

    /**
     * 精确查询预警策略
     *
     * @param id 预警策略主键
     * @return 预警策略
     */
    @Override
    public WarnStrategy selectWarnStrategyById(Long id)
    {
       return warnStrategyMapper.selectById(id);
    }


    /**
     * 查询预警策略列表
     *
     * @param warnStrategyReq 预警策略
     * @return 预警策略
     */
    @Override
    public List<WarnStrategyResp> selectWarnStrategyList(WarnStrategyReq warnStrategyReq)
    {
      return warnStrategyMapper.selectWarnStrategyList(warnStrategyReq);
    }

    @Override
    public Integer deleteWarnStrategy(Long id) {
        return warnStrategyMapper.deleteById(id);
    }


    /**
     * 修改
     */
    public Integer updWarnStrategy(WarnStrategy warnStrategy){
        QueryWrapper<WarnStrategy> wrapper = new QueryWrapper<>(warnStrategy);
        return warnStrategyMapper.update(wrapper);
    }

    /**
     * 添加
     */
    public Integer addWarnStrategy(WarnStrategy warnStrategy){
     return warnStrategyMapper.insert(warnStrategy);
    }



    /**
     * 根据车辆类型ID查询策略
     */
    @Override
    public List<WarnStrategyResp> selectListByCarType(Long carTypeId) {
        return warnStrategyMapper.selectListByCarType(carTypeId);
    }


}
